package com.jike.shop.cloud.shop;

import com.jike.shop.cloud.IShopService;
import com.jike.shop.cloud.query.ShopQueryBo;
import com.jike.shop.cloud.request.AddShopReq;
import com.jike.shop.cloud.response.CommonResp;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/shop")
public class ShopController {

    @DubboReference(version = "1.0.0", group = "jike-shop")
    private IShopService iShopService;

    @PostMapping(value = "/addGoodToShop")
    public String addGoodToShop(@RequestParam ShopQueryBo shopQueryBo){
        AddShopReq addShopReq=new AddShopReq();
        addShopReq.setProductId(shopQueryBo.setProductId());
        addShopReq.setProductPrice(shopQueryBo.getProductPrice());
        addShopReq.setProductSkuId(shopQueryBo.getProductSkuId());
        addShopReq.setProductNum(shopQueryBo.getProductNum());
        CommonResp<?> resp=iShopService.addShopCart(addShopReq);
        return resp.getCode();
    }
}
